package ast;

public class StringConstant implements Expression {

	private String value;

	public StringConstant(String value) {
		value = removeQuotesAtStartAndEnd(value);
		this.value = removeSpecialCharacters(value);
	}

	private String removeQuotesAtStartAndEnd(String value) {
		return value.substring(1, value.length() - 1);
	}

	private String removeSpecialCharacters(String value) {
		return value.replace("\\\\", "\\").replace("\\\"", "\"");
	}

	public String getValue() {
		return value;
	}

	@Override
	public void accept(Visitor visitor) {
		visitor.visitStringConstant(this);
	}

}
